//页面加载完成执行此程序
$(function(){
    $("#button").attr("disabled","disabled");
    /*v_username();v_telphone();v_name();v_email();*/
});
//提交按钮状态设置
function enableSubmit(bool){
    if(bool) {
        $("#button").removeAttr("disabled");
    } else {
        $("#button").attr("disabled","disabled");
    }
}

//验证多少项，多少个false
var flags = [false,false,false];
//flags全为true时提交按钮解除禁用
function v_submitbutton(){
    for(f in flags) if(!flags[f]) {
        enableSubmit(false);
        return;
    }
    enableSubmit(true);
}
//验证原密码
function v_original(){
    var original = $("#input1").val();
    debugger;
    $.post("/sys/user/selectLoginUser","",function(data){
        var originalPwd =  data.data.loginuser;
        $.post("/sys/user/updatePwdVerify",{"pwd":original,"originalPwd":originalPwd.password},function(data){
            var see = data.data.pwdResult;
            if(original.trim()==""||see!=true) { flags[0]=false;enableSubmit(false);
                $("#tab3-1").html("原密码不正确");$("#img-icon1-12").css("display","block");$("#tab3-1").css("display","block");$("#input1").css("border","solid 1px red");}
            else{flags[0] = true;
                $("#input1").css("border","solid 1px #2dc12d","");$("#img-icon1-11").css("display","block");$("#tab3-1").css("display","none");$("#img-icon1-12").css("display","none");}
            v_submitbutton();
        });

    });
}
function v_new(){
    var newpwd = $("#input2").val();
    if(newpwd.trim()=="") { flags[1]=false;enableSubmit(false);
        $("#tab3-2").html("新密码不能为空");$("#img-icon2-12").css("display","block");$("#tab3-2").css("display","block");$("#input2").css("border","solid 1px red");}
    else{flags[1] = true;
        $("#input2").css("border","solid 1px #2dc12d","");$("#img-icon2-11").css("display","block");$("#tab3-2").css("display","none");$("#img-icon2-12").css("display","none");}
    v_submitbutton();
}
function v_again(){
    var newpwd = $("#input2").val();
    var again = $("#input3").val();
    if(again.trim()==""||newpwd!=again) { flags[2]=false;enableSubmit(false);
        $("#tab3-3").html("两次密码不一致");$("#img-icon3-12").css("display","block");$("#tab3-3").css("display","block");$("#input3").css("border","solid 1px red");}
    else{flags[2] = true;
        $("#input3").css("border","solid 1px #2dc12d","");$("#img-icon3-11").css("display","block");$("#tab3-3").css("display","none");$("#img-icon3-12").css("display","none");}
    v_submitbutton();
}
function adaptValue(){
    return true;
}
